<template>
    <view>
        <view class="displayInputShow==='none'?'':'input-for-display'" 
		:style="{bottom:displayInputBottom}">
			<u-form class="message-input" :border-bottom="false" ref="uForm">
				<u-form-item left-icon="chat"
					:border-bottom="false"
					:left-icon-style="{color:'#adadad'}"
					class="u-p-0">
					<u-input v-model="msg" placeholder="来聊聊天～" :clearable="false"
						placeholderStyle="color:#adadad;"
						:custom-style="{color: '#fff'}">
					</u-input>
					<view slot="right">
						<u-button @click="sendMsg" :hair-line="false" shape="circle" hover-class="none" class="send-btn" size="mini">发送</u-button>
					</view>
				</u-form-item>
			</u-form>
        </view>
    </view>
</template>

<script>
	
	let setting = uni.getStorageSync("setting");
	
	import FastScanner from '@/common/fastscan.js';
	
    export default{
        props: {
            isTimReady:false
        },
        data() {
            return {
				msg: '',
				displayInputShow: 'none',
				displayInputBottom: '0px',
				sensitive: setting.live_sensitive.split(',')
			}
        },
        methods: {
            bindblur() {
                this.displayInputShow = 'none'
            },
            bindkeyboardheightchange(event) {
                this.displayInputShow = 'none'
                const {
                    height,
                    duration
                } = event.$wx.detail
                this.displayInputBottom = height + 'px'
                if (height > 0) {
                    setTimeout(()=>{
                        this.displayInputShow = 'block'
                    },duration*1000)
                }
            },
            textInput(data) {
                this.text = data.$wx.detail.value
            },
            sendMsg() {
				if(this.msg == ''){
					return this.$u.toast('消息不能为空~');
				}
				
				let hits = new FastScanner(this.sensitive).hits(this.msg);
				if(!this.isEmptyObject(hits)){
					return this.$u.toast('消息中包含敏感词汇~');
				}
                this.$emit('send-message', this.msg)
                this.msg = ''
            },
			isEmptyObject(obj) {
				var name;
				for ( name in obj ) {
					return false;
				}
				return true;
			},
        },
        computed: {}
    }
</script>
<style type="scss">
    .message-input {
        height: 64rpx;
        width: 100%;
        border-radius: 40rpx;
        border-radius: 40rpx;
        padding-left: 20rpx;
        /* padding-right: 20rpx; */
        line-height: 64rpx;
        border: 0;
        outline: none;
        font-size: 12px;
        color: #fff;
    }
    .input-for-display {
        width: 100vw;
        height: 110rpx;
        position: fixed;
        left: 0;
        background: #EDEDED;
        z-index: 10000;
    }
    .inner-input {
        background: #FFFFFF;
        border-radius: 8rpx;
        border-radius: 8rpx;
        width: 700rpx;
        margin: 20rpx auto;
        height: 68rpx;
        line-height: 68rpx;
        padding: 0 20rpx;
        font-family: PingFangSC-Regular;
        font-size: 14px;
        color: #111111;
        letter-spacing: 0;
    }
	.send-btn{
		border: none;
		height: 68rpx;
		margin-right: -2rpx;
		background: #5CB61A;
		color: #fff;
		font-size: 24rpx;
	}
</style>